﻿using B.S.BaseData.ErrorCode;
using B.S.BaseData.Read.Api.Application.Command.UserRoleCommand;
using B.S.BaseData.Read.Api.Dtos;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BaseData.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UserRoleController : ControllerBase
    {

        private readonly IMediator mediator;

        public UserRoleController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 显示用户角色
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<GetUserRoleDto>>> GetUserRole([FromQuery] GetUserRoleCommand request)
        {
            try
            {
                return mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 属于**角色的显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<GetUserRole2Dto>>> GetUserRole2([FromQuery] GetUserRole2Command request)
        {
            try
            {
                return mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
